www.gusucode.com > LTE基带收发仿真系统matlab源码程序 > LTE baseband simulation/encode_bit.m

    function [output, state] = encode_bit(g, input, state)
% 对输入的二进制序列进行编码
% 输入:
%          g:生成器
%      input:输入信息
%      state:状态器
% 输出:
%      output:编码输出
%       state:状态器
% 
%  Author:		程式小组(徐萌 张妙 张晓庆)
%  Date:		2010-07-11
%  ==========================================================

[n,k] = size(g);
m = k-1;

% determine the next output bit
for i=1:n
   output(i) = g(i,1)*input;
   for j = 2:k
      output(i) = xor(output(i),g(i,j)*state(j-1));
   end;
end

state = [input, state(1:m-1)];